<template>
  <!-- <step-nav style="margin-bottom: 0.1rem" justify="center" :active="stepNav.active" :colSize="12" :step-data="stepNav.stepData"></step-nav> -->
  <div class="ppm-container" style="height: 100vh">
    <PPMPage
      v-if="pageData.length > 0"
      :formData="formData"
      :pageData="pageData"
      @on-sumbit="testGet"
      @func="getParam"
	  @preview="preview"
    />
  </div>
</template>

<script>
import "@/crm3.0part7-ppm/styles/index.css";
import http from "@/utils/http";
import ppmmixin from "@/mixins/detailPPMmixin.js";
// import ppmmixin from "@/mixins/ppmmixin.js";
import prodSave from "@/utils/pageOfferDetailSave";
import OrderService from "@/api/order/OrderService.js";
// import StepNav from "@/components/public/StepNav";
// import { mapState } from "vuex";
export default {
  name: "ProductDetails",
  mixins: [ppmmixin],
  data() {
    return {};
  },
  created() {},
  computed: {},
  mounted() {
	  
  },
  // components: { StepNav },
  methods: {
    async testGet(params) {
      
      let result = await http({
        url: `/ppm/postT`,
        data: params,
        method: "POST",
      });
      this.resultDate = result;
    },

    getParam(data) {
      // // 
      
      // let arr = [];
      // arr.push(data);
      // //先根据产品id把对象处理成数组，数组里的对象个数对应就是产品的个数
      // arr.forEach((item) => {
      // 	this.res.result.push(Object.values(item));
      // });
      // 
    },

    Save() {
      this.saveProd();
    },
    //报文数据拼接结束
    async preview() {
      let params = prodSave.buildObject(this.formData,'330' , '38393','2045');
      const result = await prodSave.modOrderInfoByOption(params);
      if(result.resultCode=='0'){
        this.$message({
            type: "success",
            message: "保存成功!",
          });
      }else{
          this.$message({
            type: "error",
            message: "保存失败:"+result.resultMsg,
          });
       return;
      }
      this.$alert(params, {
        dangerouslyUseHTMLString: true,
      });
    },

    // 报文提交
    async saveProd() {
      let params = prodSave.buildObject(this.formData, 310, 38393);
      
	  const result = await prodSave.modOrderInfoByOption(params);
	  if(result.resultCode=='0'){
		   this.openDialog("保存成功", "", "success");
	  }else{
		  this.openDialog("保存失败", result.resultMsg, "error");
		  return;
	  }
      //const result = await OrderService.getOrderList(params);
      
      // if (result.status == -1) {
      //   this.openDialog("添加失败", result.data, "error");
      //   return;
      // }
      // this.openDialog("添加成功", "", "success");
      // this.$emit("addContactResult", result);
    },
  },
};
</script>
